<?php

header("content-type:text/html;charset=utf-8");  //设置编码

//解析config.ini文件
$config = parse_ini_file(realpath(dirname(__FILE__) . '/config/config.ini'));

//从config 中获取数据库相关属性
$servername = $config["dbServername"];
$username = $config["dbUsername"];
$password = $config["dbPassword"];
$dbName = $config["dbName"];

//数据库连接
$mysqli = new mysqli($servername, $username, $password, $dbName);

//检测连接
if(mysqli_connect_error()) {
    die("连接失败: " . $conn->connect_error);
}

//预处理及绑定
$stmt = $mysqli->prepare("INSERT INTO user(username, password) VALUES(?, ?)");
$stmt->bind_param("sd", $username, $password);

//设置参数并执行

$username = "apple";
$password = "01233";
$stmt->execute();

$username = "bananan";
$password = "0123356";
$stmt->execute();

$username = "orange";
$password = "01dff233";
$stmt->execute();

echo "新纪录插入成功";

$stmt->close();
$mysqli->close();









